#!/bin/bash

set -e

# 获取脚本所在目录
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT_DIR="$(dirname "$SCRIPT_DIR")"

UNITS_FILE="${UNITS_FILE:-$ROOT_DIR/data/processed/units_prs_open.jsonl}"
OUT_DIR="${OUT_DIR:-$SCRIPT_DIR/data/validation_results}"
MODEL_NAME="${MODEL_NAME:-Qwen/Qwen3-8B}"
BASE_URL="${BASE_URL:-https://api.siliconflow.cn}"
API_KEY="${API_KEY:-EMPTY}"

# 使用当前激活环境的 Python（可用 PYTHON_BIN 覆盖）
PYTHON_BIN="${PYTHON_BIN:-$(which python)}"

# 创建必要的目录
mkdir -p "$OUT_DIR" "$SCRIPT_DIR/logs"

# Few-shot prompt日志文件（可通过环境变量覆盖）
PROMPT_LOG_FILE="${PROMPT_LOG_FILE:-$OUT_DIR/few_shot_prompts_$(date +%F_%H%M%S).txt}"

PROMPT_LOG_FILE="$PROMPT_LOG_FILE" $PYTHON_BIN "$SCRIPT_DIR/pipeline.py" \
  --units-data-file "$UNITS_FILE" \
  --output-dir "$OUT_DIR" \
  --sample-count 10 \
  --model-name "$MODEL_NAME" \
  --api-key "$API_KEY" \
  --base-url "$BASE_URL"

echo "Done. Results in: $OUT_DIR"
echo "Few-shot prompts logged at: $PROMPT_LOG_FILE"
echo "Application logs saved in: $SCRIPT_DIR/logs/"


